/*
 * @Date: 2021-09-05 20:28:39
 * @Author: Acckno1
 * @LastEditTime: 2021-09-07 20:32:54
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 31;

int n;
int pre[N], post[N];

/**
 * @description: DFS
 * @param {int} l1 前序遍历的左边界
 * @param {int} r1 前序遍历的右边界
 * @param {int} l2 后序遍历的左边界
 * @param {int} r2 后序遍历的右边界
 * @param {string} & 
 * @return {*}
 */
int dfs(int l1, int r1, int l2, int r2, string & in) {
    
    if (l1 > r1) return 1; // 为空树 算一个合法方案
    if (pre[l1] != post[r2]) return 0;

    int cnt = 0;
    for (int i = l1; i <= r1; i ++ ) {
        string lin, rin;
        int lcnt = dfs(l1 + 1, i, l2, l2 + i - l1 - 1, lin);
        int rcnt = dfs(i + 1, r1, l2 + i - l1 - 1 + 1, r2 - 1, rin);

        if (lcnt && rcnt) {
            in = lin + to_string(pre[l1]) + ' ' + rin;
            cnt += lcnt * rcnt;
            if (cnt > 1) break;
        }
    }

    return cnt;
}

inline void solution() {
    cin >> n;
    for (int i = 0; i < n; i ++ ) cin >> pre[i];
    for (int i = 0; i < n; i ++ ) cin >> post[i];

    string in;
    int cnt = dfs(0, n - 1, 0, n - 1, in);
    if (cnt > 1) cout << "No" << endl;
    else cout << "Yes" << endl;

    in.pop_back();
    cout << in << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}